<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
    <title>分类列表</title>
</head>
<body>
<h2>分类列表</h2>
<a href="${pageContext.request.contextPath}/post/publish">发布新帖子</a>
<br><br>
<form action="${pageContext.request.contextPath}/post/category/add" method="post" style="margin-bottom: 20px;">
    <input type="text" name="name" placeholder="新分类名称" required>
    <button type="submit">添加分类</button>
</form>

<ul>
    <c:forEach var="category" items="${categories}">
        <li>
            <a href="${pageContext.request.contextPath}/post/category/${category.id}">${category.name}</a>
            <a href="${pageContext.request.contextPath}/post/category/delete/${category.id}" onclick="return confirm('确定要删除这个分类吗？')">删除</a>
        </li>
    </c:forEach>
</ul>
<br>
<a href="${pageContext.request.contextPath}/post/list">返回帖子列表</a>
</body>
</html>